/** @format */

// uno.config.ts
import { defineConfig, presetAttributify, presetMini, transformerDirectives, transformerVariantGroup } from 'unocss';
import { presetUni } from '@uni-helper/unocss-preset-uni';
import { presetApplet, presetRemRpx } from 'unocss-applet';
export default defineConfig({
 presets: [
  presetUni(),
  //@ts-ignore
  presetMini({ prefix: 'uno-' }),
 ],
 //@ts-ignore
 transformers: [transformerDirectives(), transformerVariantGroup()],
});
// 改用 post-css 处理
function pxToRpxTransformer() {
 return {
  name: 'px-to-rpx-transformer',
  enforce: 'pre', // 在其他转换器之前执行
  async transform(code, id, { uno }) {
   // code 是 MagicString 实例
   const pxRegex = /(-?\d*\.?\d+)px/g;
   // Replace px with rpx by multiplying the value by 2
   code.replace(pxRegex, (_, p1) => `${parseFloat(p1) * 2}rpx`);
  },
 };
}
